hasmany relationship in laravel

39

$movies = Movie::whereHas('director', function($q) {
    $q->where('name', 'great');
})->get();
<?php
 
namespace App\Models;
 
use Illuminate\Database\Eloquent\Model;
 
class Post extends Model
{
    /**
     * Get the comments for the blog post.
     */
    public function comments()
    {
        return $this->hasMany(Comment::class);
    }
}

Comments

Submit
0 Comments